'''
Created on 28/08/2010

@author: lctr30
'''

import inspect
import os.path
from debug.log import Logger

class MSG:
    NONE_PARAMETER = 'None Parameter - method:\'{0}\', line:\'{1}\', module:\'{2}\''

class Pemba:

    def __init__(self, log_config=None):
        self.logger = Logger().get_instance(self,log_config)
        
    def is_none(self, param):
        if param == None:
            currframe = inspect.currentframe()
            callframe = inspect.getouterframes(currframe, 2)
            method = callframe[1][4][0].strip().replace(':','')
            line = callframe[1][2]
            module = os.path.basename(callframe[1][1].strip())
            self.ERROR(MSG.NONE_PARAMETER, method, line, module)
            return True
        return False
    
    def get_not_none(self, value ,default):
        if value == None:
            return default
        return value
            

    def DEBUG(self, msg, *args):
        self.logger.debug(msg, *args)
    
    def INFO(self,msg, *args):
        self.logger.info(msg, *args)
        
    def WARN(self, msg, *args):
        self.logger.warn(msg, *args)
        
    def ERROR(self,msg, *args):
        self.logger.error(msg, *args)
        
    def CRITICAL(self, msg, *args):
        self.logger.critical(msg,args) 
        